﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Internal.Master" Inherits="BPM.Web.ViewPage" %>

<asp:Content ID="c1" ContentPlaceHolderID="TitleContent" runat="server">
	类别列表
</asp:Content>
<asp:Content ID="c3" ContentPlaceHolderID="ScriptStyleContent" runat="server">
</asp:Content>
<asp:Content ID="c2" ContentPlaceHolderID="MainContent" runat="server">
	<%
		var firstLevelCategories = this.ViewData["CategoryLevelOne"] as BPM.Entity.MaterialDefinitionCategory[];
		var allCates = this.ViewData["AllCates"] as IGrouping<int?, BPM.Entity.MaterialDefinitionCategory>[];
	%>
	<div>
		<input type="button" value="添加大类别" onclick="addCate();" />
	</div>
	<% 
		if (firstLevelCategories != null && firstLevelCategories.Length > 0)
		{ %>
	<div>
		<ul>
			<%
				foreach (var firstLevelCate in firstLevelCategories)
				{
					var name = firstLevelCate.Name;
					var id = firstLevelCate.Id;
					var childrenCates = allCates.FirstOrDefault(g => g.Key == id);
					var sign = childrenCates != null ? "+" : "-";
			%>
			<li><a href="javascript:;" onclick="toggleSubCate(<%=id %>, '<%=name %>');" id="bigCateTitle_<%=id %>">
				<%= sign%>
				<%= name%>
			</a><a href="javascript:;" onclick="addSubCate(<%=id %>, '<%=name %>');" style="border: 0px;">
				<img src='<%=url("~/images/c/add.png") %>' border="0" alt="添加子类别" /></a> <a href="javascript:;"
					onclick="editCate(<%=id %>, '<%=name %>');">
					<img src='<%=url("~/images/c/edit.png") %>' border="0" alt="编辑" /></a> <a href="javascript:;"
						onclick="deleteCate(<%=id %>);">
						<img src='<%=url("~/images/c/delete.png") %>' border="0" alt="删除" /></a>
				<%
					if (childrenCates != null)
					{
				%>
				<ul id="childCate_<%=id %>" style="display: none;">
					<%
						foreach (var childCate in childrenCates)
						{
							var childId = childCate.Id;
							var childName = childCate.Name;
					%>
					<li>
							<%= childName%>
						<a href="#" onclick="editCate(<%=childId %>, '<%= childName%>');">
							<img src='<%=url("~/images/c/edit.png") %>' border="0" alt="编辑" /></a> <a href="#"
								onclick="deleteCate(<%=childId %>);">
								<img src='<%=url("~/images/c/delete.png") %>' border="0" alt="删除" /></a>
					</li>
					<%
						}
					%>
				</ul>
				<%
					}
				%>
			</li>
			<%
				}
			%>
		</ul>
	</div>
	<%}
		else
		{ %>
	<p style="text-align: center;">
		未创建任何类别
	</p>
	<%} %>
	<div id="divPopup" style="display: none;">
		<div>
			类别名称:&nbsp;<input type="text" id="txtCateName" />
		</div>
		<div style="text-align: right; margin-top: 10px; width: 97%;">
			<input onclick="submitData();" type="button" value="确认" />
		</div>
	</div>
</asp:Content>
